﻿Type.registerNamespace("Samples");

// ZipCodeValueHandler object

Samples.ZipCodeValueHandler = function(leafItem) {
    Samples.ZipCodeValueHandler.initializeBase(this, [leafItem]);
}

Samples.ZipCodeValueHandler.prototype = {
    getPrefixBox : function() {
        if (this.prefixBox == null) {
            this.prefixBox = $(this.getLeafNode()).children('.Prefix')[0];
        }
        return this.prefixBox;
    },
    
    getSuffixBox : function() {
        if (this.suffixBox == null) {
            this.suffixBox = $(this.getLeafNode()).children('.Suffix')[0];
        }
        return this.suffixBox;
    },       
    
    getControlValue: function() {        
        return this.getPrefixBox().value + '-' + this.getSuffixBox().value;
    },

    setControlValue: function(value) {
        if (value == null || value == '') return;
        this.getPrefixBox().value = value.substring(0, 2);
        this.getSuffixBox().value = value.substring(3, 6);
    }       
}

BM.ValueHandler['ZipCodeValueHandler'] = Samples.ZipCodeValueHandler;
Samples.ZipCodeValueHandler.registerClass("Samples.ZipCodeValueHandler", BM.ValueHandler);